import {createRouter,createWebHistory} from 'vue-router'
import {useUserStore} from "@/stores/user.js";
//导入组件

// import ArticleCategoryVue from '@/views/article/ArticleCategory.vue';
// import ArticleManageVue from '@/views/article/ArticleManage.vue';
// import UserAvatarVue from '@/views/user/UserAvatar.vue';
// import UserInfoVue from '@/views/user/UserInfo.vue';
// import UserResetPasswordVue from '@/views/user/UserResetPassword.vue';
// import ArticleAuditVue from '@/views/article/ArticleAudit.vue';
// import ArticleShowVue from '@/views/article/ArticleShow.vue';


// import HomeVue from '@/views/Home.vue'
// import IndexVue from '@/views/Index.vue'
// import Login from '@/views/Login.vue'
// import caidanVue from '@/views/caidan.vue'
// import LayoutVue from '@/views/Layout.vue'
// import CompetitionVue from '@/views/match/Competition.vue'
// import ProjectManagerVue from '@/views/project/ProjectManager.vue'
// import ResultVue from '@/views/project/Result.vue'
// import JoinVue from '@/views/user/Join.vue'
// import QueryVue from '@/views/user/Query.vue'
// import UserInfoVue from '@/views/user/UserInfo.vue'




//定义路由关系
/* const routes=[
    {path:'/login',component:LoginVue},
    {path:'/home',component:IndexVue},
        {path:'/',component:LayoutVue,redirect:'/article/manage',children:[
            {path:'/article/category',component:ArticleCategoryVue},
            {path:'/article/manage',component:ArticleManageVue},
            {path:'/user/avatar',component:UserAvatarVue},
            {path:'/user/info',component:UserInfoVue},
            {path:'/user/resetPassword',component:UserResetPasswordVue},
            {path:'/article/audit',component:ArticleAuditVue},
            {path:'/article/show/:articleId',name:'article-show',component:ArticleShowVue}

        ]}
] */


        // const routes=[
        //     {path:'/login',component:LoginVue},
        //     { path: '/', redirect: '/login' },
        //     {path:'/home',component:IndexVue},
        //     {path:'/',component:LayoutVue,redirect:'/project/manage',children:[
        //         {path:'/match/competition',component:CompetitionVue},
        //         {path:'/project/manage',component:ProjectManagerVue},
        //         {path:'/project/result',component:ResultVue},
        //         {path:'/user/join',component:JoinVue},
        //         {path:'/user/query',component:QueryVue},
        //         {path:'/user/userInfo',component:UserInfoVue}
        //     ]}
        // ]


//创建路由器
const router=createRouter({
    history:createWebHistory(),
    routes:[
        { path: '/login', component: () => import('@/views/login.vue') },
        { path: '/', redirect: '/login' },
        { path: '/index', component: () => import('@/views/index.vue') },
        { path:'/user/join',component: () => import('@/views/user/Join.vue') },
        { path:'/user/mymatch',component: () => import('@/views/user/Mymatch.vue') },
        { path:'/user/userInfo',component: () => import('@/views/user/UserInfo.vue') },
        { path:'/match/geren',component: () => import('@/views/match/geren.vue') },
        { path:'/match/team',component: () => import('@/views/match/team.vue') },
        { path:'/match/refereeScoring',component: () => import('@/views/match/RefereeScoring.vue')},
        { path:'/match/gerenScore',component: () => import('@/views/match/gerenScore.vue')},
        { path:'/match/teamScore',component: () => import('@/views/match/teamScore.vue')},

       

        //管理员功能：
        { path: '/admin/manage', component: () => import('@/views/Layout.vue'),
            redirect:'/admin/main',
            children:[
                { path:'/user/query',component: () => import('@/views/user/Query.vue') },
                { path:'/manage/userList',component: () => import('@/views/admin/userList.vue') },
                // { path:'/user/userInfo',component: () => import('@/views/user/UserInfo.vue') },
                { path:'/match/competition',component: () => import('@/views/match/Competition.vue') },
                { path:'/manage/collegeList',component: () => import('@/views/admin/collegeList.vue') },
                { path:'/match/scoreManage',component: () => import('@/views/match/ScoreManage.vue') },
                { path:'/manage/information',component: () => import('@/views/admin/Information.vue') },
                { path:'/admin/main',component: () => import('@/views/admin/Main.vue')},
                { path:'/match/teamGrade',component: () => import('@/views/match/teamGrade.vue')},
                { path:'/manage/gerenShow',component: () => import('@/views/admin/gerenShow.vue')},
                { path:'/manage/teamShow',component: () => import('@/views/admin/teamShow.vue')},
                { path:'/match/gerenGrade',component: () => import('@/views/match/gerenGrade.vue')},

            ]
        },
        //普通用户及裁判员功能
        // { *******
        //     children:[
        //         { ******** },
        //         { ********* },
        //     ]
        // },
    ]
    
})
//配置路由守卫
/*router.beforeEach((to, from, next) => {
    const userStore = useUserStore();
    if (to.meta.requiresAuth && !userStore.userName) {
        // 未登录且尝试访问需要授权的页面
        next('/login');
    } else {
        next();
    }
});*/

//导出路由
export default router